package graph;

import java.util.ArrayList;

@SuppressWarnings("all")
public abstract class Node {
	private final static int SYSTEM = 0;
	private final static int SCHEDULER = 1;

	private int owner;
	private int n;

	ArrayList<TaskConfiguration> taskConfigurations = new ArrayList<TaskConfiguration>();

	public Node(ArrayList<TaskConfiguration> taskConfigurations) {
		n = taskConfigurations.size();
		this.taskConfigurations = taskConfigurations;
	}

	public boolean failure() {
		for (TaskConfiguration tc : taskConfigurations)
			if (tc.failure())
				return true;
		return false;
	}

	public ArrayList<TaskConfiguration> taskConfigurations() {
		return taskConfigurations;
	}

	public boolean equals(Node n) {
		if (n.taskConfigurations().size() != taskConfigurations.size()) {
			return false;
		} else {
			for (int i = 0; i < taskConfigurations.size(); i++) {
				if (!taskConfigurations.get(i).equals(n.taskConfigurations().get(i)))
					return false;
			}
		}
		return true;
	}

	public String toString(){
		String result = "";
		for(TaskConfiguration tc : taskConfigurations){
			result += tc.toString() + "\n";
		}
		return result;
	}
	
	public abstract ArrayList<Node> successors();

	public abstract ArrayList<Node> predecessors();
}
